 import * as React from "react"

// export default class Loading extends React.Component {
//   render() {
//     return (
//       <div>
//         <div className="am-loading page">
//           <i className="am-icon loading" aria-hidden="true"></i>
//           <div className="am-loading-text">加载中</div>
//         </div>
//       </div>
//     )
//   }
// }


export default function LoadingComponent(props) {
  if (props.error) {
    // When the loader has errored
    console.log("loadingComponent Error:",props.error)
    return <div>Error! <button onClick={ props.retry }>Retry</button></div>;
  } else if (props.timedOut) {
    // When the loader has taken longer than the timeout
    return <div>Taking a long time... <button onClick={ props.retry }>Retry</button></div>;
  } else if (props.pastDelay) {
    // When the loader has taken longer than the delay
    return (
        <div>
          <div className="am-loading page">
            <i className="am-icon loading" aria-hidden="true"></i>
            <div className="am-loading-text">加载中</div>
          </div>
        </div>
      );
  } else {
    // When the loader has just started
    return null;
  }
}